﻿<UserControl x:Class="BizControl.Presentation.GraphModule.Views.GraphView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:graph="clr-namespace:BizControl.Presentation.Infrastructure.Controls.Graph;assembly=BizControl.Presentation.Infrastructure"
             xmlns:graphSharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
             xmlns:infra="clr-namespace:BizControl.Presentation.Infrastructure.Controls;assembly=BizControl.Presentation.Infrastructure">

    <UserControl.Resources>
        <DataTemplate x:Key="defaultVertexTemplate" DataType="{x:Type graph:GraphVertex}">
            <StackPanel Orientation="Horizontal" Margin="5">
                <Image Source="{StaticResource defaultUserImage}" Width="20" Height="20" />
                <TextBlock Text="{Binding Path=Data}" Foreground="Black" />
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="vertexTemplate" DataType="{x:Type graph:GraphVertex}">
            <infra:CurrentUserControl DataContext="{Binding Path=Data}" />
        </DataTemplate>

        <DataTemplate x:Key="vertexTemplate2" DataType="{x:Type graph:GraphVertex}">
            <StackPanel Orientation="Horizontal" Margin="5">
                <infra:MarkControl DataContext="{Binding Path=Data}" />
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="groupVertexTemplate" DataType="{x:Type graph:GraphVertex}">
            <StackPanel Orientation="Vertical" Background="{x:Null}">
                <Border CornerRadius="10, 10, 10, 10" Margin="10">
                    <TextBlock Text="{Binding Data}" Margin="5" Background="WhiteSmoke" />
                </Border>
                <graph:BCGraphControl DataContext="{Binding ChildModel}" Background="{x:Null}" />
            </StackPanel>
        </DataTemplate>


        <Style TargetType="{x:Type graphSharp:VertexControl}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type graphSharp:VertexControl}">
                        <Border BorderBrush="Black" Background="{x:Null}" BorderThickness="2"
                                CornerRadius="10,10,10,10" Padding="{TemplateBinding Padding}">
                            <ContentPresenter x:Name="mainContent" Content="{TemplateBinding Vertex}" />
                            <Border.Effect>
                                <DropShadowEffect BlurRadius="2" Color="LightGray" Opacity="0.3" Direction="315"/>
                            </Border.Effect>
                        </Border>
                        <ControlTemplate.Triggers>
                            <DataTrigger Binding="{Binding ElementName=mainContent, Path=DataContext.ID}" Value="user">
                                <Setter TargetName="mainContent" Property="ContentTemplate" Value="{DynamicResource vertexTemplate}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=mainContent, Path=DataContext.ID}" Value="mark">
                                <Setter TargetName="mainContent" Property="ContentTemplate" Value="{DynamicResource vertexTemplate2}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=mainContent, Path=DataContext.ID}" Value="default">
                                <Setter TargetName="mainContent" Property="ContentTemplate" Value="{DynamicResource defaultVertexTemplate}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=mainContent, Path=DataContext.ID}" Value="group">
                                <Setter TargetName="mainContent" Property="ContentTemplate" Value="{DynamicResource groupVertexTemplate}" />
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--<DataTemplate x:Name="edgeTemplate" DataType="{x:Type graphSharp:EdgeControl}">
            <StackPanel Orientation="Horizontal" Margin="5" ToolTip="{Binding Path=ID}" />
        </DataTemplate>-->

        <Style TargetType="{x:Type graphSharp:EdgeControl}">
            <Setter Property="Foreground" Value="Black" />
            <!--<Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type graphSharp:EdgeControl}">
                        <ContentPresenter x:Name="mainContent" Content="{TemplateBinding Edge}" 
                                          ToolTip="{Binding Path=ID}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>-->
        </Style>

    </UserControl.Resources>

    <Grid>
        <Border CornerRadius="20" BorderBrush="#FF393939" BorderThickness="10" Margin="10" Background="{x:Null}">
            <graph:BCGraphControl DataContext="{Binding}" Background="{x:Null}" />
        </Border>
    </Grid>
</UserControl>
